package com.ruoyi.web.controller.mall.shopExpressMessage.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.shopExpressMessage.domain.ShopExpressMessage;
import com.ruoyi.web.controller.mall.shopExpressMessage.service.IShopExpressMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 快递单信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/shopExpressMessage")
public class ShopExpressMessageController extends BaseController
{
    private String prefix = "mall/shopExpressMessage";

    @Autowired
    private IShopExpressMessageService shopExpressMessageService;

//    @RequiresPermissions("mall:shopExpressMessage:view")
    @GetMapping()
    public String shopExpressMessage()
    {
        return prefix + "/shopExpressMessage";
    }

    /**
     * 查询快递单信息列表
     */
//    @RequiresPermissions("mall:shopExpressMessage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ShopExpressMessage shopExpressMessage)
    {
        startPage();
        List<ShopExpressMessage> list = shopExpressMessageService.selectShopExpressMessageList(shopExpressMessage);
        return getDataTable(list);
    }

    /**
     * 导出快递单信息列表
     */
//    @RequiresPermissions("mall:shopExpressMessage:export")
    @Log(title = "快递单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ShopExpressMessage shopExpressMessage)
    {
        List<ShopExpressMessage> list = shopExpressMessageService.selectShopExpressMessageList(shopExpressMessage);
        ExcelUtil<ShopExpressMessage> util = new ExcelUtil<ShopExpressMessage>(ShopExpressMessage.class);
        return util.exportExcel(list, "shopExpressMessage");
    }

    /**
     * 新增快递单信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存快递单信息
     */
//    @RequiresPermissions("mall:shopExpressMessage:add")
    @Log(title = "快递单信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ShopExpressMessage shopExpressMessage)
    {
        return toAjax(shopExpressMessageService.insertShopExpressMessage(shopExpressMessage));
    }

    /**
     * 修改快递单信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ShopExpressMessage shopExpressMessage = shopExpressMessageService.selectShopExpressMessageById(id);
        mmap.put("shopExpressMessage", shopExpressMessage);
        return prefix + "/edit";
    }

    /**
     * 修改保存快递单信息
     */
//    @RequiresPermissions("mall:shopExpressMessage:edit")
    @Log(title = "快递单信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ShopExpressMessage shopExpressMessage)
    {
        return toAjax(shopExpressMessageService.updateShopExpressMessage(shopExpressMessage));
    }

    /**
     * 删除快递单信息
     */
//    @RequiresPermissions("mall:shopExpressMessage:remove")
    @Log(title = "快递单信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(shopExpressMessageService.deleteShopExpressMessageByIds(ids));
    }
}
